﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace DentistOffice
{
    public partial class Shoutbox : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            czytajKrzyk();
            Response.AddHeader("Refresh", "5;URL=Shoutbox.aspx");
        }
        protected string czytajKrzyk()
        {
            FileStream fs = new FileStream(System.AppDomain.CurrentDomain.BaseDirectory + "\\krzyk.txt", FileMode.Open, FileAccess.Read, FileShare.Read);
            fs.Close();
            StreamReader sr = new StreamReader(System.AppDomain.CurrentDomain.BaseDirectory + "\\krzyk.txt");
            string bufor, calosc = "";
            List <string> shouty = new List<string>();
            while ((bufor = sr.ReadLine()) != null)
            {
                shouty.Add(bufor);
            }
            sr.Close();
            for (int i = shouty.Count - 1; i >= 0; i--)
            {
                if(i % 2 == 0)
                    tkrzyk.Text += "<div class=\"k1\">" + shouty[i] + "</span>";
                else
                    tkrzyk.Text += "<div class=\"k2\">" + shouty[i] + "</span>";
            }
            return calosc;
        }
    }
}